<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>父类方法的重写</title>
  </head>
  <body>
    <script>
      // 父类
      class Phone {
        // 构造方法
        constructor(brand, price) {
          this.brand = brand;
          this.price = price;
        }
        call(brand) {
          console.log(`${brand}手机能打电话`);
        }
      }
      // 子类
      class SmartPhone extends Phone {
        constructor(brand, price, color, size) {
          super(brand, price);
          this.color = color;
          this.size = size;
        }
        photo() {
          console.log("能拍照");
        }
        call() {
          console.log("能打视频电话");
        }
      }
      // 实例化子类
      const xiaomi = new SmartPhone("小米", 1999, "白色", 5.5);
      console.log(xiaomi);
      xiaomi.call(); // 能打视频电话  调用的是子类重写的方法
    </script>
  </body>
</html>
